<template>
  <div>
    <el-card shadow="never">
      <div class="card-query">
        <div>
          <el-button
            icon="el-icon-document-add"
            type="primary"
            @click="handleAdd"
            >添加</el-button
          >
          <el-button
            icon="el-icon-refresh"
            type="primary"
            @click="handleRefresh"
            >刷新</el-button
          >
        </div>
      </div>
    </el-card>

    <el-table
      :data="tableData"
      style="width: 100%"
      :header-cell-style="{ textAlign: 'center' }"
      :cell-style="{ textAlign: 'center' }"
    >
      <el-table-column label="#">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="支付类型">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            <el-tag size="medium">{{ scope.row.payType }}</el-tag>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="描述">
        <template slot-scope="scope">
          <div slot="reference" class="name-wrapper">
            {{ scope.row.describe }}
          </div>
        </template>
      </el-table-column>
      <el-table-column label="是否启用">
        <template slot-scope="scope">
          <el-switch
            v-model="scope.row.isEnable"
            @change="change(scope.$index, scope.row)"
          >
          </el-switch>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
            >编辑</el-button
          >
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <!-- 添加框 -->
    <el-dialog title="支付类型" :visible.sync="dialogFormVisible" width="500px">
      <el-form ref="form" :model="form" :rules="rules">
        <el-form-item
          label="支付类型"
          :label-width="formLabelWidth"
          prop="type"
        >
          <el-input v-model="form.username" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item
          label="描述"
          :label-width="formLabelWidth"
          prop="describe"
        >
          <el-input v-model="form.describe" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirm('form')">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dialogFormVisible: false,
      formLabelWidth: "100px",
      form: {
        type: "",

        describe: "",
      },
      rules: {
        type: [{ required: true, message: "请输入支付类型", trigger: "blur" }],
      },
      tableData: [
        {
          id: 1,
          payType: "银联支付",
          isEnable: true,

          describe:
            "作为中国的银行卡联合组织，实现了系统间的互联互通，进而使银行卡得以跨银行、跨地区和跨境使用",
        },
        {
          id: 2,
          payType: "在线预存",
          isEnable: true,

          describe:
            "作为中国的银行卡联合组织，实现了系统间的互联互通，进而使银行卡得以跨银行、跨地区和跨境使用",
        },
        {
          id: 3,

          payType: "第三方支付（支付宝）平台",
          isEnable: true,

          describe: "在线支付（第三方支付平台）支付宝，微信，财付通等",
        },
        {
          id: 4,
          payType: "信用卡、储蓄卡",
          isEnable: true,

          describe: "直接使用开通的信用卡支付",
        },
        {
          id: 5,
          payType: "货到付款",
          isEnable: true,

          describe:
            "在线支付是指卖方与买方通过因特网上的电子商务网站进行交易时，银行为其提供网上资金结算服务的一种业务。它为企业和个人提供了一个安全、快捷、方便的",
        },
      ],
    };
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    //添加
    handleAdd() {
      this.dialogFormVisible = true;
    },
    //刷新
    handleRefresh() {
      location.reload();
    },
  },
};
</script>

<style>
</style>